home *** CD-ROM | disk | FTP | other *** search
- #include <stdlib.h>
- #include <string.h>
- #include <osbind.h>
- #include <stdio.h>
- #include "st52.h"
-
- /* Most of the cookie code here by Eric R. Smith */
-
- /* we use a union because most cookie tags are 4 ASCII characters, so it
- may be useful to sometimes think of them as strings. On the other hand,
- they *are* longwords, so we may want to access them that way, too
- */
-
- union clong {
- char aschar[4];
- long aslong;
- };
-
- /*
- * a cookie consists of 2 longwords; a tag and a value. The tag is normally
- * chosen to have some sort of significance when represented as 4 ascii
- * characters (see the union definition above). What the value represents
- * is dependent on the tag; it may be an address (for a TSR), or a version
- * number (e.g. MiNT does this), or whatever (it may not even have a meaning).
- */
-
- struct cookie {
- union clong tag;
- long value;
- };
-
- typedef struct cookie COOKIE;
-
- /*
- * A pointer to the cookie jar is found at 0x5a0. If there is no cookie jar
- * installed, this pointer will be 0. The cookie jar itself is an array
- * of cookies, with the last cookie having a "tag" of 0x00000000. (The value
- * of this cookie is the number of slots left in the cookie jar.)
- */
-
- #define CJAR ((COOKIE **) 0x5a0)
-
- long
- getcookie(char *cookieid)
- {
- char biscuit[5];
- long retval = 0L;
- long ssp;
- char *p;
- COOKIE *cookie;
-
- ssp = Super(0L);
- cookie = *CJAR;
-
- if (cookie) {
- while (cookie->tag.aslong != 0) {
- p = cookie->tag.aschar;
- sprintf(biscuit, "%c%c%c%c%c%c", p[0], p[1], p[2], p[3], '\000');
- if (strncmp(cookieid, biscuit, 4) == 0) {
- retval = (cookie->value);
- break;
- }
- cookie++;
- }
- }
- ssp = Super(ssp);
- return (retval);
- }
-
-